import React, { useState } from 'react'
import { LoginStyle } from './style'
import { TextField, Button } from '@material-ui/core'
import { useHistory } from 'react-router-dom'
const Login = function(props) {

  const [formData, setFormData] = useState({
    userCode: '',
    password: ''
  })

  const history = useHistory()

  function onSubmit() {
    history.push('./home')
  }

  return <LoginStyle>
    <h2 className="login_title">登录</h2>
    <form className="login_box">
        <TextField
          label="输入用户名"
          placeholder="测试admin"
          fullWidth
          value={formData.userCode}
          />
        <TextField
          label="输入密码"
          type="password"
          placeholder="6位数的密码"
          fullWidth
          value={formData.password}
        />
        <Button
          className="login_button"
          variant="contained"
          color="primary"
          size="small"
          onClick={onSubmit}
        >登录</Button>
    </form>
  </LoginStyle>
}

export default Login